//
//  HuiCell.m
//  JinChengYun
//
//  Created by 金橙云 on 2017/3/13.
//  Copyright © 2017年 金橙云. All rights reserved.
//

#import "HuiCell.h"

@implementation HuiCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self createUI];
        UIImageView *lineImg = [[UIImageView alloc] init];
        lineImg.backgroundColor = [UIColor orangeColor];
        [self addSubview:lineImg];
        [lineImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(4, 60));
            make.left.mas_equalTo(self.mas_left).offset(10);
            make.top.equalTo(self.mas_top).offset(7);
        }];
        //头像
        _imgView = [[UIImageView alloc] init];
        // _imgView.backgroundColor = [UIColor redColor];
        _imgView.image = [UIImage imageNamed:@"nanshihui"];
        [self addSubview:_imgView];
        [_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(15, 16));
            make.left.equalTo(lineImg.mas_left).offset(10);
            make.top.equalTo(self.mas_top).offset(8);
        }];
        
        //客户姓名
        _nameLab = [[UILabel alloc] init];
        _nameLab.textColor = OverColor;
        _nameLab.font = [UIFont systemFontOfSize:14];
        _nameLab.textAlignment = NSTextAlignmentLeft;
        _nameLab.text = @"陈晓燕";
        // _nameLab.backgroundColor = [UIColor yellowColor];
        [self addSubview:_nameLab];
        [_nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(60, 18));
            make.left.equalTo(_imgView.mas_right).offset(8);
            make.top.equalTo(self.mas_top).offset(8);
        }];
        
        //签约日期
        _qianDateLab = [[UILabel alloc] init];
        _qianDateLab.text = @"签约日期 | 2017-02-09";
        _qianDateLab.font = [UIFont systemFontOfSize:10];
        _qianDateLab.textColor = [UIColor blackColor];
        [self addSubview:_qianDateLab];
        [_qianDateLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(150, 16));
            make.left.equalTo(_nameLab.mas_right).offset(15);
            make.top.equalTo(self.mas_top).offset(10);
        }];
        
        _typeLab =  [[UILabel alloc] init];
        _typeLab.text = @"资料不全";
        _typeLab.font = [UIFont systemFontOfSize:10];
        _typeLab.textColor = [UIColor blackColor];
        [self addSubview:_typeLab];
        [_typeLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(80, 16));
            make.left.equalTo(_qianDateLab.mas_right).offset(15);
            make.top.equalTo(self.mas_top).offset(10);
             make.right.equalTo(self.mas_right).offset(-15);
        }];

        
        
        
        //签约房源
        _qianFangLab = [[UILabel alloc] init];
        _qianFangLab.text = @"签约房源 | 1号楼2单元2311房";
        _qianFangLab.font = [UIFont systemFontOfSize:10];
        _qianFangLab.textColor = [UIColor blackColor];
        [self addSubview:_qianFangLab];
        [_qianFangLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(180, 16));
            make.left.equalTo(self.mas_left).offset(40);
            make.top.equalTo(self.mas_top).offset(30);
        }];
        //贷款类型
        _daiStlyLab = [[UILabel alloc] init];
        _daiStlyLab.text = @"贷款类型 | 公积金贷款";
        _daiStlyLab.font = [UIFont systemFontOfSize:10];
        _daiStlyLab.textColor = [UIColor blackColor];
        [self addSubview:_daiStlyLab];
        [_daiStlyLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(110, 16));
            make.left.equalTo(self.mas_left).offset(40);
            make.top.equalTo(self.mas_top).offset(50);
        }];
        //贷款金额
        _daiMoneyLab = [[UILabel alloc] init];
        _daiMoneyLab.text = @"贷款金额 | 2000000元";
        _daiMoneyLab.font = [UIFont systemFontOfSize:10];
        _daiMoneyLab.textColor = [UIColor blackColor];
        [self addSubview:_daiMoneyLab];
        [_daiMoneyLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(110, 16));
            make.left.equalTo(_daiStlyLab.mas_right).offset(5);
            make.top.equalTo(self.mas_top).offset(50);
        }];
        
//        //实缴首付
//        _shiJiaoLab = [[UILabel alloc] init];
//        _shiJiaoLab.text = @"实缴首付 | 1002000元";
//        _shiJiaoLab.font = [UIFont systemFontOfSize:10];
//        _shiJiaoLab.textColor = [UIColor blackColor];
//        [self addSubview:_shiJiaoLab];
//        [_shiJiaoLab mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.size.mas_equalTo(CGSizeMake(110, 16));
//            make.left.equalTo(self.mas_left).offset(40);
//            make.top.equalTo(self.mas_top).offset(70);
//        }];
//        //总欠首付
//        _zongQianLab = [[UILabel alloc] init];
//        _zongQianLab.text = @"总欠首付 | 1208999元";
//        _zongQianLab.font = [UIFont systemFontOfSize:10];
//        _zongQianLab.textColor = [UIColor blackColor];
//        [self addSubview:_zongQianLab];
//        [_zongQianLab mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.size.mas_equalTo(CGSizeMake(110, 16));
//            make.left.equalTo(_shiJiaoLab.mas_right).offset(5);
//            make.top.equalTo(self.mas_top).offset(70);
//        }];
        //打电话按钮
        _callBtn = [[UIButton alloc] init];
        [_callBtn setBackgroundImage:[UIImage imageNamed:@"dianhuatubiao"] forState:0];
        [_callBtn addTarget:self action:@selector(callPhoBtnClick:) forControlEvents:UIControlEventTouchUpInside];
             _callBtn.mm_acceptEventInterval = 10;
        [self addSubview:_callBtn];
        [_callBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(25);
            make.left.equalTo(self.mas_right).offset(-50);
            make.top.equalTo(self.mas_top).offset(30);
        }];
        
        //电话号码
        _phoneNumber = [[UILabel alloc] init];
        [self addSubview:_phoneNumber];
        
    }
    return self;
}

-(void)setUpHuiMoneyCellWithName:(NSString *)_name withYueTime:(NSString *)_yue withYUeHouse:(NSString *)_house withDaiState:(NSString *)_dai withDaiMoney:(NSString *)_money withPhone:(NSString *)_phone withTypeString:(NSString *)_type
{
    _nameLab.text = _name;
    _qianDateLab.text = [NSString stringWithFormat:@"签约日期 | %@",_yue];
    _typeLab.text = [NSString stringWithFormat:@"%@",_type];
    _qianFangLab.text = [NSString stringWithFormat:@"签约房源 | %@",_house];
    _daiStlyLab.text = [NSString stringWithFormat:@"贷款类型 | %@",_dai];
    _daiMoneyLab.text = [NSString stringWithFormat:@"贷款金额 | %@",_money];
    _phoneNumber.text = _phone;
}
-(void)callPhoBtnClick:(UIButton *)btn
{
    NSMutableString *str=[[NSMutableString alloc] initWithFormat:@"tel:%@",_phoneNumber.text];
    UIWebView *callWebview = [[UIWebView alloc] init];
    [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
    [self addSubview:callWebview];
}

- (void)createUI{
    //创建一个UIView比self.contentView小一圈
    self.bgView  = [[UIView alloc] initWithFrame:CGRectMake(10,4, SCREEN_WIDTH-10*2, 64)];
    self.bgView.backgroundColor = [UIColor whiteColor];
    //给bgView边框设置阴影
    self.bgView.layer.shadowOffset = CGSizeMake(2,2);
    self.bgView.layer.shadowOpacity = 0.3;
    self.bgView.layer.shadowColor = [UIColor blackColor].CGColor;
    [self.contentView addSubview:self.bgView];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
